// 商户停车场审核记录加载
window.onload = function () {
    var url = 'http://192.168.0.106:8080/MerchantParking/getAllParkInfoByPage'
    function s(datas) {
        function operateFormatter(value, row, index) {//赋予的参数
            return [
                "<button  class='btn btn-primary' style='margin-right:10px' onclick=detailsmerchant(" + row.bsubmitparkid + ")>详情</button>",
            ].join('');
        }
        // 设置table列样式
        function formatFormatter(value, row, index) {
            if (value == 1) {

                return [
                    '<span>已处理</span>',
                ].join('');
            } else {
                return [
                    '<span>未处理</span>',
                ].join('');
            }
        }
        var tableColumns = [
            {
                field: 'bsparkauditrecordid',
                title: 'ID',
                switchable: true
            }, {
                field: 'name',
                title: '名称',
                switchable: true
            },
            {
                field: 'addtime',
                title: '添加时间',
                switchable: true,
            },
            {
                field: 'iscontrolflag',
                title: '是否处理',
                formatter: formatFormatter
            }, {
                field: 'operate',
                title: '操作',
                formatter: operateFormatter //自定义方法，添加操作按钮
            }
        ];
        $("#merchanttable").bootstrapTable('destroy'); //分页必须写
        $("#merchanttable").bootstrapTable({
            cache: false,
            pagination: true,
            sidePagination: "client",  //分页方式：client客户端分页，server服务端分页（*）
            pageNumber: 1,   //初始化加载第一页，默认第一页
            pageSize: 5,   //每页的记录行数（*）
            pageList: [5, 10], //可供选择的每页的行数
            columns: tableColumns,
            data: datas,
            queryParamsType: '',
            //得到查询的参数
            queryParams: function queryParams(params) {
                return params;
            },
            onLoadSuccess: function (data) {  //加载成功时执行
                alert("成功" + data)
            },
            onLoadError: function () {  //加载失败时执行
                alert("失败")
            }

        });
    }
    $.ajax({
        url: url,
        method: 'post',
        contentType: "application/x-www-form-urlencoded",
        success: function (res) {
            console.log(res.data)
            s(res.data)

        }
    })
}
function backmerchant(e) {
    // 返回
    divset = document.getElementsByClassName("search");
    for (var i = 0; i < divset.length; i++) {
        divset[i].style.display = "inline";
    };
    divsetadd = document.getElementsByClassName("detailsmerchant");
    for (var i = 0; i < divset.length; i++) {
        divsetadd[i].style.display = "none";
    };
}
function detailsmerchant(bsubmitparkid) {
    console.log(bsubmitparkid)
    $.ajax({
        url: "http://192.168.0.106:8080/MerchantParking/getDetails",
        method: "post",
        contentType: "application/x-www-form-urlencoded",
        data: {
            bSubmitParkID: bsubmitparkid
        },
        success: function (res) {
            console.log(res.data)
            $("#name").html(res.data[0].name)
            $("#address").html(res.data[0].address)
            switch (res.data[0].parktypeid) {
                case 1:
                    $("#contentype").val("室内")
                    break;
                case 2:
                    $("#contentype").val("室外")
                    break;
                case 3:
                    $("#contentype").val("路边")
                    break;
                default:
                    break;
            }

           
            switch (res.data[0].auditstatus) {
                case 0:
                $("#status").val("待审核")
                    break;
                case 1:
                $("#status").val("审核通过")
                    break;
                case 2:
                $("#status").val("审核不通过")
                    break;
                default:
                    break;
            }
            $("#total").html(res.data[0].totalplacenum)
            $("#phone").html(res.data[0].contactphone)
            $("#phoneMana").html(res.data[0].managermobile)
            $("#timeMana").html(res.data[0].busistarttime+"-"+res.data.busiendtime)
            $("#shoufei").html(res.data[0].shoufeiinfo)
            $("#tianjia").html(res.data[0].addtime)
            $("#chulitime").html(res.data[0].controlTime)
            $("#chilipeple").html(res.data[0].systemUserID)
            $("#chuliname").html(res.data[0].systemUserName)
            $("#namefull").html(res.data[0].manager)
            console.log(res.data[0].shoufeiinfo)
            
            
        //  轮播
        var imageURL= res.data[0].imgList
        console.log(imageURL[0])
                            //填充每幅图像的具体信息
                            for(var i = 0; i < imageURL.length; i++) {
                                if(i == 0) {
                                    $("#lunbo").append("<div class='item active'>" +
                                            "<img src='" + imageURL[i] + "' alt='52'>" +
                                            "<div class='carousel-caption'>" +
                                            "<p> " + "第" + i + "</p>" +
                                            "</div>" +
                                            "</div>");
                                } else {
                                    $("#lunbo").append("<div class='item'>" +
                                            "<img src='" + imageURL[i] + "' alt=''>" +
                                            "<div class='carousel-caption'>" +
                                            "<p> " + "第" + i + "</p>" +
                                            "</div>" +
                                            "</div>");
                                }
                            }
        }
    })
    // 详情
    divset = document.getElementsByClassName("search");
    for (var i = 0; i < divset.length; i++) {
        divset[i].style.display = "none";
    };
    divsetedit = document.getElementsByClassName("detailsmerchant");
    for (var i = 0; i < divset.length; i++) {
        divsetedit[i].style.display = "inline";
    };

}